package com.michael.demos.base.design.adapter.spring;

/**
 * 类功能描述:
 * <pre>
 *   定义一个Adapter接口
 * </pre>
 *
 * @author Michael
 * @version 1.0
 * @date 2020/8/17 15:48
 */
public interface HandlerAdapter {
	boolean supports(Object handler);

	void handle(Object handler);
}

/**
 * 多种适配器类
 */
class SimpleHandlerAdapter implements HandlerAdapter {

	@Override
	public boolean supports(Object handler) {
		return handler instanceof SimpleController;
	}

	@Override
	public void handle(Object handler) {
		((SimpleController) handler).doSimplerHandler();
	}

}

class HttpHandlerAdapter implements HandlerAdapter {

	@Override
	public boolean supports(Object handler) {
		return handler instanceof HttpController;
	}

	@Override
	public void handle(Object handler) {
		((HttpController) handler).doHttpHandler();
	}

}

class AnnotationHandlerAdapter implements HandlerAdapter {

	@Override
	public boolean supports(Object handler) {
		return handler instanceof AnnotationController;
	}

	@Override
	public void handle(Object handler) {
		((AnnotationController) handler).doAnnotationHandler();
	}

}
